﻿#include <stdio.h>
int main()
{
	int m = 0;
	int n = 0;
	scanf("%d %d", &m, &n);
	int k = (m > n ? n : m);
	while (1)
	{
		if (m % k == 0 && n % k == 0)
		{
			break;
		}
		k--;
	}
	printf("%d\n", k);
	return 0;
}

//⽅法=2

#include <stdio.h>
int main()
{
	int m = 0;
	int n = 0;
	scanf("%d %d", &m, &n);
	int k = 0;
	while (k = m % n)
	{
		m = n;
		n = k;
	}
	printf("%d\n", n);
	return 0;
}

int gcd(int a, int b) 
{
	if (b == 0) 
	{
		return a;
	}
	return gcd(b, a % b);
}